/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.client.informes;

import edu.uoc.tdp.beans.informes.Universitat;
import edu.uoc.tdp.beans.proves.Prova;
import edu.uoc.tdp.common.EOlympicsException;
import edu.uoc.tdp.common.EOlympicsUtils;
import edu.uoc.tdp.common.RemotInformesInterface;
import edu.uoc.tdp.common.TDSLanguageUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.*;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 * Pantalla pel cas d'ús Consula de proves finalitades.
 * Informe que permet als usuaris de perfil estudiant i als de perfil gestor, obtenir els resultats de les proves finalitzades. S’accedeix des de la opció de menú inclosa en el menú específic d’estadístiques o bé clicant el botó corresponent de la pantalla d’informes de l’estudiant / gestor.
 * @author joboni
 */
public class PantallaProvesFinalitzades extends javax.swing.JFrame {
    
    private RemotInformesInterface remot;
    private DefaultTableModel dtm;
    private javax.swing.JTable jTable1;
    private javax.swing.JScrollPane jScrollPane2;
    /**
     * Creates new form PantallaProvesFinalitzades
     */
    public PantallaProvesFinalitzades() {
        try {
            initComponents();
            inicialitzarComponets();
        } catch (MalformedURLException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_RMI_URL"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (NotBoundException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_RMI_INIT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (RemoteException e) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_REMOT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
    
    /**
     * Metode per inicialitzar els components de la pantalla ( Literalas, mides, taules...)
     * @throws IOException
     * @throws NotBoundException
     * @throws RemoteException
     * @throws EOlympicsException 
     */
    private void inicialitzarComponets() throws IOException, NotBoundException, RemoteException, EOlympicsException{
        //Literals
        TDSLanguageUtils.setDefaultLanguage("edu/uoc/tdp/i18n/messages");
        
        //Recuperem les universitats
        ArrayList<Universitat> universitats = new ArrayList<Universitat>();
        universitats.add(null);
        universitats.addAll(Arrays.asList(Universitat.values()));
        //Introduim les universitats en el Combo
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(universitats.toArray()));
        //Literals
        panelFiltre.setBorder(javax.swing.BorderFactory.createTitledBorder(TDSLanguageUtils.getMessage("informes.filtre")));
        ltitol.setText(TDSLanguageUtils.getMessage("informes.subtitol"));
        jLabel2.setText(TDSLanguageUtils.getMessage("informes.universitat"));
        jLabel3.setText(TDSLanguageUtils.getMessage("informes.prova"));
        jLabel4.setText(TDSLanguageUtils.getMessage("informes.dinscripciofins"));
        jLabel5.setText(TDSLanguageUtils.getMessage("informes.drealitzaciofins"));
        jLabel6.setText(TDSLanguageUtils.getMessage("informes.fins"));
        jLabel7.setText(TDSLanguageUtils.getMessage("informes.fins"));
        jTextField1.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField2.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField3.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jTextField4.setText(TDSLanguageUtils.getMessage("informes.formatdata"));   
        jButton1.setText(TDSLanguageUtils.getMessage("informes.filtrar"));   
        setTitle(TDSLanguageUtils.getMessage("informes.titol"));
        
        //Conexió RMI
        Properties prop = new Properties();
        URL url = ClassLoader.getSystemResource("edu/uoc/tdp/properties/configuration.properties");
        prop.load(url.openStream());
        remot=(RemotInformesInterface)Naming.lookup(prop.getProperty("pathrmi_informes"));
        //Recuperem les proves tancades
        List<Prova> proves = remot.getProvesTancades();
        //Posem una prova com a null
        proves.add(0,new Prova(null, ""));
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(proves.toArray()));
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new JTable(dtm);
        jTable1.setAutoCreateRowSorter(true);
        jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        jScrollPane2.setViewportView(jTable1);
        //Posem el tamany de la taula
        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        actualitzarTaula(null,null,null,null,null,null);

    }
    /**
     * Método per actualitzar el contingut de la taula. Mostra els resultats a partir dels camps introduits per pantalla
     * @param idUniversitat Universitat
     * @param idProva Id intern de la prova
     * @param dinscripcio_ini Data inici d'inscripció
     * @param dinscripcio_fi Data fi d'inscripció de la prova
     * @param drealitacio_ini Data inici de la realització de la ronda
     * @param drealitacio_fi Data fi de la realització de la prova
     * @throws RemoteException
     * @throws EOlympicsException 
     */
    private void actualitzarTaula(String idUniversitat, Integer idProva, Date dinscripcio_ini,
            Date dinscripcio_fi, Date drealitacio_ini, Date drealitacio_fi) throws RemoteException, EOlympicsException{
        //Recuperem les proves tancades corresponents a la consulta
        ArrayList<HashMap> resultats = remot.consultarProves(idUniversitat,idProva,
                dinscripcio_ini,dinscripcio_fi,drealitacio_ini,drealitacio_fi);
        //Creem el model de la taula de resultats de la consulta
        String [] columnes = new String [] {
                "",
                TDSLanguageUtils.getMessage("informes.prova"),
                TDSLanguageUtils.getMessage("informes.tipus"),
                TDSLanguageUtils.getMessage("informes.preguntes"),
                TDSLanguageUtils.getMessage("informes.dinscripcio"),
                TDSLanguageUtils.getMessage("informes.dinscripcio"),
                TDSLanguageUtils.getMessage("informes.drealitzacio"),
                TDSLanguageUtils.getMessage("informes.drealitzacio"),
                TDSLanguageUtils.getMessage("informes.places"),
                TDSLanguageUtils.getMessage("informes.participants"),
                TDSLanguageUtils.getMessage("informes.inscripcions"),
                TDSLanguageUtils.getMessage("informes.encerts"),
                TDSLanguageUtils.getMessage("informes.errors"),
                TDSLanguageUtils.getMessage("informes.blanc"),
                TDSLanguageUtils.getMessage("informes.total"),
                TDSLanguageUtils.getMessage("informes.min"),
                TDSLanguageUtils.getMessage("informes.max"),
            };
        Object [][] dades = new Object [resultats.size()][17];
        
        
        dtm= new DefaultTableModel(dades, columnes);
        jTable1.setModel(dtm);
        
        int i = 0;
        //Recorrem la consulta i la introduim a la  taula
        for (HashMap resultat : resultats){
            dtm.setValueAt(resultat.get("IDPROVA"), i, 0);
            dtm.setValueAt(resultat.get("DESCRIPCIO"), i, 1);
            dtm.setValueAt(resultat.get("TIPUS"), i, 2);
            dtm.setValueAt(resultat.get("NUMPREGUNTES"), i, 3);
            dtm.setValueAt(EOlympicsUtils.getStringDate((Date)resultat.get("DINSCRIPCIO_INI")), i, 4);
            dtm.setValueAt(EOlympicsUtils.getStringDate((Date)resultat.get("DINSCRIPCIO_FI")), i, 5);
            dtm.setValueAt(EOlympicsUtils.getStringDate((Date)resultat.get("DREALITZACIO_INI")), i, 6);
            dtm.setValueAt(EOlympicsUtils.getStringDate((Date)resultat.get("DREALITZACIO_FI")), i, 7);
            dtm.setValueAt(resultat.get("NUMPLACES"), i, 8);
            dtm.setValueAt(resultat.get("PARTICIPANTS"), i, 9);
            dtm.setValueAt(resultat.get("INSCRITS"), i, 10);
            dtm.setValueAt(resultat.get("ENCERTS"), i, 11);
            dtm.setValueAt(resultat.get("ERRORS"), i, 12);
            dtm.setValueAt(resultat.get("BLANC"), i, 13);
            dtm.setValueAt(resultat.get("TOTAL"), i, 14);
            dtm.setValueAt(resultat.get("MIN"), i, 15);
            dtm.setValueAt(resultat.get("MAX"), i, 16);
            
            i++;
            
        }
        //Introduim un click de click sobre la fila per obrir el detall
        jTable1.addMouseListener(new java.awt.event.MouseAdapter(){
            @Override
            public void mouseClicked(java.awt.event.MouseEvent e){
                int row=jTable1.rowAtPoint(e.getPoint());
                PantallaDetallProva pantalla = new PantallaDetallProva(new Integer(jTable1.getValueAt(row,0).toString()), jTable1.getValueAt(row,2).toString());
                pantalla.setLocationRelativeTo(null);
                pantalla.setVisible(true);
            }

        });
        //Amagem la primera columna
        jTable1.getColumnModel().getColumn(0).setMaxWidth(0);
	jTable1.getColumnModel().getColumn(0).setMinWidth(0);
        jTable1.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
        jTable1.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
        if ((resultats==null)||(resultats.size()<=0)){
            JOptionPane.showMessageDialog(null,TDSLanguageUtils.getMessage("informes.noresultats"));
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        ltitol = new javax.swing.JLabel();
        panelFiltre = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(900, 766));

        ltitol.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        ltitol.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        ltitol.setText("Resultat proves finalitzades");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(ltitol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(ltitol)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        panelFiltre.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        panelFiltre.setToolTipText("");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Universitat");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Prova");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("jLabel4");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("jLabel5");

        jTextField1.setText("jTextField1");
        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField1FocusLost(evt);
            }
        });

        jTextField2.setText("jTextField2");
        jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField2FocusLost(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("jLabel6");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("jLabel7");

        jTextField3.setText("jTextField3");
        jTextField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField3FocusLost(evt);
            }
        });

        jTextField4.setText("jTextField4");
        jTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField4FocusLost(evt);
            }
        });

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelFiltreLayout = new javax.swing.GroupLayout(panelFiltre);
        panelFiltre.setLayout(panelFiltreLayout);
        panelFiltreLayout.setHorizontalGroup(
            panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFiltreLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(38, 38, 38)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jComboBox2, 0, 102, Short.MAX_VALUE))
                .addGap(27, 27, 27)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelFiltreLayout.createSequentialGroup()
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(183, Short.MAX_VALUE))
                    .addGroup(panelFiltreLayout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1)
                        .addGap(26, 26, 26))))
        );
        panelFiltreLayout.setVerticalGroup(
            panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFiltreLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelFiltreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setToolTipText("Hola");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 75, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelFiltre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelFiltre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp Data inici inscripció
     * @param evt 
     */
    private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField1.getText().trim())){
            jTextField1.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }
    }//GEN-LAST:event_jTextField1FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp Data fi inscripció
     * @param evt 
     */
    private void jTextField2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField2FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField2.getText())){
            jTextField2.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }        
    }//GEN-LAST:event_jTextField2FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp inici realització
     * @param evt 
     */
    private void jTextField3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField3FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField3.getText())){
            jTextField3.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        }        
    }//GEN-LAST:event_jTextField3FocusLost
    /**
     * Métode per inicialitzar el camp data a dd/mm/yyy del camp fi realització
     * @param evt 
     */
    private void jTextField4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusLost
        if(!EOlympicsUtils.isValidDate(jTextField4.getText())){
            jTextField4.setText(TDSLanguageUtils.getMessage("informes.formatdata"));
        } 
    }//GEN-LAST:event_jTextField4FocusLost
    /**
     * Métode que recuperar els camps de la pantalla un cop s'ha fet click en el butó buscar.
     * @param evt 
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            //Recuperem els camps de la pantalla
            String idUniversitat = null;
            if (jComboBox1.getSelectedItem()!=null){
                idUniversitat= ((Universitat)jComboBox1.getSelectedItem()).getDescripcio();
            }
            Prova prova = ((Prova)jComboBox2.getSelectedItem());
            Date dinscripcioinit = null;
            if(EOlympicsUtils.isValidDate(jTextField1.getText().trim())){
                dinscripcioinit = EOlympicsUtils.getDateSimpleFormat(jTextField1.getText().trim());
            }
            Date dinscripciofin = null;
            if(EOlympicsUtils.isValidDate(jTextField3.getText().trim())){
                dinscripciofin = EOlympicsUtils.getDateSimpleFormat(jTextField3.getText().trim());
            }
            
            Date drealitzacioinit = null;
            if(EOlympicsUtils.isValidDate(jTextField2.getText().trim())){
                drealitzacioinit = EOlympicsUtils.getDateSimpleFormat(jTextField2.getText().trim());
            }
            Date drealitzaciofin = null;
            if(EOlympicsUtils.isValidDate(jTextField4.getText().trim())){
                drealitzaciofin = EOlympicsUtils.getDateSimpleFormat(jTextField4.getText().trim());
            }
            //Actualitzem la taula
            actualitzarTaula(idUniversitat, prova.getIdProva(),dinscripcioinit,dinscripciofin,drealitzacioinit,drealitzaciofin );
        } catch (RemoteException ex) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERR_REMOT"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (EOlympicsException ex) {
            JOptionPane.showMessageDialog(null, TDSLanguageUtils.getMessage("informes.ERROR"), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JLabel ltitol;
    private javax.swing.JPanel panelFiltre;
    // End of variables declaration//GEN-END:variables
}



